#include <mqueue.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
int main(int argc, char** argv)
{
    mqd_t mqd;
    struct mq_attr attr;
    if(argc != 2){
        printf("usage: mgqgetattr <name>\n");
        exit(-1);
    }
    mqd = mq_open(argv[1], O_RDONLY);
    if( mqd <0){
        perror("Error");
    }
    
    mq_getattr(mqd, &attr);
    printf("max #msgs = %ld, max #bytes/msg = %ld, #currently on queue = %ld \n", 
           attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
    mq_close(mqd);
    exit(0);
}

    
    
